<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>${fns:getConfig('productName')} 登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="renderer" content="webkit">
 	<meta http-equiv="X-UA-Compatible" content="IE=edge">
 	<meta content="always" name="referrer">
    <title>${fns:getConfig('productName')} 登录</title>
    <link rel="shortcut icon" href="${ctxStatic}/images/favicon.ico"  sizes="32x32" /> 
    <link href="${ctxStatic}/common/login.css" rel="stylesheet" type="text/css"/>
	<script src="${ctxStatic}/jquery/jquery-1.12.4.min.js" type="text/javascript"></script>	
    <link href="${ctxStatic}/bootstrap/3.3.6/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
   	<link href="${ctxStatic}/bootstrap/3.3.6/css_hplus/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
   	<link href="${ctxStatic}/bootstrap/3.3.6/css_hplus/css/animate.min.css" rel="stylesheet">
	<link href="${ctxStatic}/bootstrap/3.3.6/css_hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
	<link href="${ctxStatic}/bootstrap/3.3.6/css_hplus/css/plugins/toastr/toastr.min.css" rel="stylesheet">	
	
	<script src="${ctxStatic}/common/minglead.js" type="text/javascript"></script>
	
	<script type="text/javascript">    
		// 如果在框架或在对话框中，则弹出提示并跳转到首页
 		if(self.frameElement && self.frameElement.tagName == "IFRAME" || $('#left').length > 0 || $('.jbox').length > 0){
			alert('未登录或登录超时。请重新登录，谢谢！');
			top.location = "${ctx}";
		}

		$(document).ready(function() {
			var msg='${message}';
			if(msg!=''){
				 toastr.error(msg);
			}			    
				    
		});
		$(document).keydown(function(event){
			if(event.keyCode==13&&event.target.id!='username'){
				event.preventDefault();
				form_sub();
			} 
		});
					
			function form_sub(){
						
			var username=$('#username');
			var password=$('#password');
			var validateCode=$('#validateCode');
			if(username.val()==''){
			$('#messageBox').show();
			$('#loginError').html("请填写用户名！");
				 username.focus();
				 return false;
			}
			if(password.val()==''){
			$('#messageBox').show();
			$('#loginError').html("请填写密码！");
				 password.focus();
				 return false;
			}
			if(validateCode.val()==''){
			
			$('#messageBox').show();
			$('#loginError').html("请填写验证码！");		
				 validateCode.focus();
				 return false;
			}
			
            var validateCode = validateCode.val();
            var username = $("#username").val();
            var password = $("#password").val();
 			var newPassword = compileStr(password);	   
            //登录校验
			$.ajax({
				url:"${ctxAdmin}/loginNew?validateCode="+validateCode,
				type:'post',
				dataType:'json',
				data:{password:newPassword,username:username},
				success:function(result){
			
				var code = result.code;
				var message = result.message;
				if(code==1){
				 window.location = "${ctxAdmin}";
				}else{
				 alert(message);
				 window.location = window.location;
				}
				}
			}); 
			
			 
		}

var isIE8 = isIE8();
$(function(){
        if(isIE8){
        $('#username').css('background','none');
        $('#password').css('background','none');
        }
});


	</script>
</head>

<body style="min-height: 768px;">


	<div class="header">
		<div id="messageBox" class="alert alert-error ${empty message ? 'hide' : ''}"><button data-dismiss="alert" class="close">×</button>
			<label id="loginError" class="error">${message}</label>
		</div>
	</div>

	<div class="wrap">
		<div class="header clearfix">
			<div class="logo left"></div>
			<div class="words left">
				<p class="Bwords">${fns:getConfig('productName')}</p>			
				<p>${fns:getConfig('productNameSubTitle')}</p>
			</div>
		</div>

		<div class="body">
			<div class="login">
				<ul>
					<li><p class="title">用户登录</p></li>
								
					<li class="username"><input type="text" value="" name="" placeholder="用户名" id="username"  autofocus="autofocus"></li>
					<li class="password"><input type="password" value="" id="password"></li>
					
					
					<li class="verification">
					<input type="text" id="validateCode" name="validateCode" maxlength="4" style="width: 160px;height: 30px;" placeholder="验证码"/>
					
			
					<img id="validate_img" style="height: 30px;width: 100px;" title="看不清？点击刷新" src="${ctx}/servlet/validateCodeServlet?height=40&width=100" onclick="$(this).attr('src','${ctx}/servlet/validateCodeServlet??height=40&width=100&random='+Math.random());"/>				
								
					</li>
											                         									
				
					<li class="btn">		
					<button id="btn_sub" onclick="form_sub()">登陆</button>
	                <input type="submit" style="display: none" id="loginSub"/>
	                <!-- <a class="btn-sub" id="btn_sub" onclick="form_sub()">登&nbsp;录</a>	 -->              	
	                									
					</li>
				</ul>
			</div>
		</div>
	</div>	

	<!--底部内容-->
	<div class="bottom" style="bottom: 10%;clear: both;color: #cccccc;font-weight:bold;height: 30px;left: 42%;position: absolute;text-align: center;">
	    <p> &copy; ${year} ${fns:getConfig('productName')}</p>
	    <p>快速开发手册</p>
	</div>	
			        
</body>
</html>